<?php


namespace Agoni;


//use Hanson\Foundation\Foundation;
use Agoni\MeiTuan\MeiTuan;
use Agoni\DaDa\DaDa;
use Agoni\DaDa\Test;

/**
 * Class Dispatch
 * @package Agoni\MeituanDispatch
 *
 * @property \Agoni\Test         $test
 *
 * @method array createByShop($params)
 * @method array queryStatus($params)
 * @method array createByCoordinates($params)
 * @method array delete($params)
 * @method array evaluate($params)
 * @method array check($params)
 * @method array location($params)
 */
class Dispatch
{
    private $order;
    private $config=[];
    public $test=null;

    public function __construct($config)
    {
        $this->config=$config;
        //$this->test=new Test($config['app_key'], $config['secret']);
        //默认美团
        //$this->order = new MeiTuan($config['app_key'], $config['secret'],$config['source_id']);
    }
    public function methond($tag){
        switch ($tag){
            case 'MeiTuan':
                $this->order=new MeiTuan($this->config['app_key'],$this->config['secret']);
                return $this;
                break;
            case 'DaDa':
                $this->order=new DaDa($this->config['app_key'],$this->config['secret'],$this->config['source_id']);
                $this->test=new Test($this->config['app_key'],$this->config['secret'],$this->config['source_id']);
                return $this;
                break;
        }
    }
    public function __call($name, $arguments)
    {
        if($name!='method'){
            return $this->order->{$name}(...$arguments);
        }
    }
}